<template>
	<u-popup v-model="show" mode="center" border-radius="16">
		<view class="cancel-pop-content">
			<view class="header-wrap">
				<text class="header-title">提示</text>
			</view>
			<view class="pop-content">
				<text>确认解绑此设备吗?</text>
			</view>
			<view class="btn-box-wrap">
				<u-button @click="handleClose">取消</u-button>
				<u-button type="primary" @click="handleConfirm">确定</u-button>
			</view>
		</view>
	</u-popup>
</template>

<script>
	import { request, showLoading, toast } from "@/utils/tool.js"
	export default {
		data() {
			return {
				show: false,
				shebei_id: ""
			}
		},
		emits: ["success"],
		methods: {
			async handleConfirm() {
				const { shebei_id } = this
				if (!shebei_id) return
				const hide = showLoading()
				const resp = await request({
					url: "/shebei/jiebang",
					method: "POST",
					data: { shebei_id }
				}).catch(hide)
				if (resp.code !== 1) return hide()
				this.$emit("success")
				this.shebei_id = ""
				toast({ title: "解绑成功", icon: "success" })
				this.handleClose()
			},
			open(shebei_id) {
				this.show = true
			},
			handleClose() {
				this.show = false
			}
		},
	}
</script>

<style lang="scss" scoped>
	.cancel-pop-content {
		padding: 46rpx 70rpx 72rpx;
		width: 600rpx;
		box-sizing: border-box;
		position: relative;

		.btn-box-wrap {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 50rpx;
		}

		.pop-content {
			font-size: 32rpx;
			color: #737373;
			letter-spacing: 1px;
			line-height: 44rpx;
			margin-top: 40rpx;
			text-align: center;
		}

		.btn-box {
			display: flex;
			align-items: center;
			margin-top: 42rpx;

			.btn-item {
				flex: 1;
				height: 122rpx;
				border-radius: 16rpx 16rpx 16rpx 16rpx;
				border: 2rpx solid #3361F0;
				display: flex;
				align-items: center;
				box-sizing: border-box;
				position: relative;

				.btn-icon {
					width: 50rpx;
					height: 50rpx;
				}

				.btn-title {
					font-weight: 400;
					font-size: 28rpx;
					color: #000000;
					line-height: 40rpx;
					margin-left: 20rpx;
				}

				&:first-child {
					margin-right: 58rpx;
				}
			}
		}


		.close-icon {
			width: 40rpx;
			height: 40rpx;
			position: absolute;
			top: 50%;
			right: 16rpx;
			transform: translateY(-50%);
			border: 1px solid #f00;
		}

		.header-wrap {
			display: flex;
			align-items: center;
			justify-content: center;
			position: relative;

		}

		.header-title {
			font-weight: 400;
			font-size: 32rpx;
			color: #000000;
			letter-spacing: 1px;
			line-height: 44rpx;
			text-align: center;
		}


	}
</style>